import QtQuick 2.9
import QtQuick.Window 2.1
import "coderain.js" as Rainer

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Code rain")

    Canvas {
        id: canvas
        anchors.fill: parent
        focus: true

        onWidthChanged: {
            var count = Math.ceil(canvas.width / 10);
            Rainer.arr = new Array(count)
            for(var index = 0;index < count;index++) {
                Rainer.arr[index] = 0;
            }
        }

        onPaint: {
            Rainer.rain(canvas);
        }

        Timer{
            interval: 30; running: true; repeat: true
            onTriggered: {
                canvas.requestPaint();
            }
        }
    }
}
